<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(!empty($_RQ['title'])){
		$params['content like']='%'.trim($_RQ['content']).'%';
		$return['params']['content']=$_RQ['content'];
	}
   // $fields=array('id','name');
    $orderby='id desc';
	$total='';
	$return['list']=pdo_getslice('jy_sns_post',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['bid']=pdo_getcolumn('jy_sns_board',array('id'=>$v['bid']),'title');
		$v['pid']=pdo_getcolumn('jy_sns_post',array('id'=>$v['pid']),'title');
		$v['name']=pdo_getcolumn('core_members',array('id'=>$v['mid']),'nickname');
	}
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'评论管理'),
			
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'bid','title'=>'所属版块','type'=>'string'),
			array('name'=>'pid','title'=>'所属话题','type'=>'string'),
			array('name'=>'content','title'=>'内容','type'=>'string'),
			array('name'=>'name','title'=>'昵称','type'=>'string'),

		)),
		'search'=>array(
			array('name'=>'content','width'=>15,'title'=>'内容','type'=>'string'),
		)
	);
	$return['enabled']=array('0'=>'禁用','1'=>'启用');
	$return['htmls']=$htmls;
	exi($return);
	}


if($_RQ['op']=='del'){

	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_sns_post',array('id'=>$id));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_sns_post',array('id'=>$id));
			}
		}
	}
	exi('删除成功！');
}
?>